<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/2/20 0020
 * Time: 14:06
 */

//注册自加载

spl_autoload_register('autoload');

function autoload($class)
{
    require dirname($_SERVER['SCRIPT_FILENAME']) . '//..//' . str_replace('\\', '/', $class) . '.php';
}

/*********** test *************/

use factoryAbstract\AnimalFactory;
use factoryAbstract\PlantFactory;

//动物生产线
$animal = new AnimalFactory();
//植物生产线
$plant = new PlantFactory();


/**
 * 动物工厂和植物工厂
 * 农场接口和园林接口
 * 实例
 * @param \factoryAbstract\Factory $factory
 */
function call(\factoryAbstract\Factory $factory)
{
    $earn = function (\factoryAbstract\Income $income) {
        $income->money();
    };

    $earn($factory->createZoo());
    $earn($factory->createFarm());
}

call($animal);
call($plant);

